<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Modify Personnel Password</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>basic/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
	<!-- 表单校验 -->
	<jsp:include page="/resources/resource-refer/component-validform-reference.jsp" />
  </head>
  <script type="text/javascript">
  	function submitForm() {
  		//原密码
	  	var currPassword = $("input[name='currPassword']").val();
	  	//新密码
	  	var setupPassword = $("input[name='setupPassword']").val();
	  	//重复新密码
	  	var reSetupPassword = $("input[name='reSetupPassword']").val();
	  	$.getJSON(path+"basic/userAction!modifyUserPwd.do?date="+new Date(), {
	  		currPassword: $.trim(currPassword),
	  		setupPassword: $.trim(setupPassword),
	  		reSetupPassword: $.trim(reSetupPassword)
	  	}, function(data) {
	  		if(data.success) {
	  			Dialog.alert("Successful Operation！", function() {
	  				parent.window.frames["c_content_content"].location = path + "basic/jsp/welcome.jsp?date="+new Date();
	  			});
	  		} else {
	  			Dialog.alert(data.msg);
	  		}
	  	});
  	}
  	
  	$(function(){
		$("form[name='modifyPwdForm']").Validform({
			btnSubmit: "input[name='submit']",
			btnReset: "input[name='reset']",
			tiptype: function(msg, o, cssctl){
				//msg：提示信息;
				//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
				//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
				if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				} else {
					var objtip=o.obj.find("#msgdemo");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
			},
			postonce: true, //开启二次提交防御，在数据成功提交后，表单将不能再继续提交
			showAllError: true, //提交表单时所有错误提示信息都会显示
			beforeSubmit: function(curform) { //在验证成功后，表单提交前执行的函数，curform参数是当前表单对象
				submitForm();
				return true; //这里明确return false的话表单将不会提交
			}
		});
  	});
  </script>
  <body>
  	<div class="content_all">
  		<!--查询条件-->
	  	<div class="search">
	    	<p><font style="font-weight: bolder;">Tips</font>：</p>
      		<p>1、<font color="red" style="font-weight: bolder;"> Account Security Prompt:</font>Please change password per month.</p>
      		<p>2、<font color="red" style="font-weight: bolder;">Password length should be exceed<font color="red" style="font-weight: bolder;">6 chars</font></p>
	  	</div>
  		<!--导航条-->
  		<div class="insertinfo_table">
      		<form action="#" name="modifyPwdForm"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        		<tr>
          			<th>Old Password：</th>
          			<td><input name="currPassword" type="password" class="s_input" 
          				ajaxurl="<%=basePath%>basic/formAsyncValidateActionJson!validUserPassword.do"
          				datatype="s6-15" nullmsg="Please enter old password！" errormsg="Password length in 6~15！"/>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Password length in 6~15！</div></td>
        		</tr>
        		<tr>
          			<th>New Password：</th>
          			<td><input name="setupPassword" type="password" class="s_input" 
          				datatype="s6-15" nullmsg="Please enter new password！" errormsg="Please enter new password，password length in 6~15！"/>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter new password，password length in 6~15！</div></td>
        		</tr>
        		<tr>
		          	<th>Repeat New Password：</th>
		          	<td><input name="reSetupPassword" type="password" class="s_input" 
		          		datatype="*" recheck="setupPassword" nullmsg="Please enter new password again！" errormsg="The password don't match！"/>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter new password！</div></td>
        		</tr>
        		<tr>
		          	<th></th>
		          	<td>
          				<input name="submit" type="button" value="Submit" class="s_btn" />
            			<input name="reset" type="reset" value="Reset" class="s_btn"/></td>
        		</tr>
      		</table></form>
  		</div>
	</div>
	<div class="clear"></div>
  </body>
</html>
